<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="./css/common.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/icon.css"/>
		<title>定检风机</title>
		<style type="text/css">
			.regular-check-container .mui-control-content {
				height: 100%;
				font-size: 15px;
			}
			.mui-segmented-control.mui-segmented-control-inverted .mui-control-item.mui-active {
				color: #003C6D;
				border: 0;
			}
			.mui-segmented-control .mui-control-item {
				line-height: 48px;
			}
			.mui-segmented-control .mui-active .txt {
				border-bottom: 2px solid #003C6D;
				height: 100%;
				display: inline-block;
				padding: 0 10px;
			}
			.regular-scroll .mui-table {
				table-layout: auto;
			}
			.regular-simple-list .mui-table-view-cell:nth-child(2n) {
				background-color: #F8F8F8;
			}
			.regular-draft-list .label {
				color: #999999;
			}
			.manager {
				margin: 10px 0;
			}
			.custom-dialog {
				left: 50%!important;
				top: 50%!important;
				transform: translate(-50%, -50%);
				width: 90%;
			}
			.custom-dialog .mui-popover-arrow {
				display: none;
			}
			.custom-dialog-wrap {}
			.dialog-header {
				padding: 10px 15px;
				position: relative;
			}
			.dialog-header:after {
				position: absolute;
				right: 0;
				bottom: 0;
				left: 0;
				height: 1px;
				content: '';
				-webkit-transform: scaleY(.5);
				transform: scaleY(.5);
				background-color: #c8c7cc;
			}
			.dialog-header .title {
				line-height: 16px;
				padding-left: 12px;
				color: #999999;
				border-left: 3px solid #FA8100;
			}
			.dialog-main {
				padding: 0;
				font-size: 15px;
			}
			.dialog-footer {
				position: relative;
			}
			.dialog-footer:before {
				position: absolute;
				right: 0;
				top: 0;
				left: 0;
				height: 1px;
				content: '';
				-webkit-transform: scaleY(.5);
				transform: scaleY(.5);
				background-color: #c8c7cc;
			}
			.dialog-footer .mui-table-cell {
				line-height: 50px;
			}
			.select-member .label {
				color: #999999;
			}
			.mui-table-view-cell>a:not(.mui-btn).flex {
				display: -webkit-flex;
				display: -ms-flexbox;
				display: flex;
				justify-content: space-between;
			}
			.members {
				word-break: break-all;
				word-wrap: break-word;
				white-space: normal;
				max-width: 60%;
				margin-right: 20px;
			}
			.navbar-icon {
				width: 20px;
				height: 20px;
				vertical-align: middle;
			}
			.mui-btn-outlined.mui-btn-primary {
				color: #2064AD;
				/* border-color: #2064AD; */
				border: 0;
				margin: 10px;
				padding: 3px 10px;
			}
			.hairline-top-bottom {
				position: relative;
			}
			.hairline-top-bottom:after,
			.tab-wrap:after {
				position: absolute;
				right: 0;
				left: 0;
				height: 1px;
				content: '';
				-webkit-transform: scaleY(.5);
				transform: scaleY(.5);
				background-color: #c8c7cc;
			}
			.hairline-top-bottom:after {
				bottom: 0;
			}
			.tab-wrap {
				position: relative;
				background-color: #FFFFFF;
			}
			.tab-wrap:after {
				bottom: 0;
			}
			.syncing {
				display: inline-block;
				-webkit-animation: mysync 1s linear infinite;
				animation: mysync 1s linear infinite;
			}
			@-webkit-keyframes mysync {
				from {
					-webkit-transform: rotate(0deg);
				}
				to {
					-webkit-transform: rotate(360deg);
				}
			}
			@keyframes mysync{
				from {
					transform: rotate(0deg);
				}
				to {
					transform: rotate(360deg);
				}
			}
			.mui-btn-primary:enabled:active {
				border: 0;
			}
			.arrow-icon {
				font-size: 13px;
			}
		</style>
	</head>
	<body>
		<div id="container">
			<header class="mui-bar mui-bar-nav">
				<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
				<h1 class="mui-title">定检风机</h1>
				<a class="mui-pull-right header-right" id="sync"><i class="iconfont icon-sync" :class="{ syncing: syncing }"></i> 同步数据</a>
			</header>
			<div class="mui-content regular-check-container">
				<!-- tab -->
				<div class="tab-wrap">
					<div id="segmentedControl" class="mui-segmented-control mui-segmented-control-inverted">
						<a class="mui-control-item mui-active" href="#item1"><span class="txt">待定检风机</span></a>
						<a class="mui-control-item" href="#item2"><span class="txt">草稿箱</span></a>
						<a class="mui-control-item" href="#item3"><span class="txt">定检记录</span></a>
					</div>
				</div>
				<div id="tab-content">
					<div id="item1" class="mui-control-content mui-active">
						<div v-if="willCheckList.length" class="mui-text-right hairline-top-bottom" style="background-color: #FFFFFF;">
							<button type="button" class="mui-btn mui-btn-primary mui-btn-outlined" @tap="sortList('code', currentCodeOrder)">风机编号 <i class="iconfont arrow-icon" :class="[currentCodeOrder === 'codeDown' ? 'icon-sort-down' : 'icon-sort-up' ]"></i></button>
							<button type="button" class="mui-btn mui-btn-primary mui-btn-outlined" @tap="sortList('time', currentTimeOrder)">时间 <i class="iconfont arrow-icon" :class="[currentTimeOrder === 'timeDown' ? 'icon-sort-down' : 'icon-sort-up' ]"></i></button>
						</div>
						<div id="item1-scroll" style="position: relative;" :style="{height: height1 + 'px'}">
							<div id="scroll" class="regular-scroll mui-scroll-wrapper">
								<div class="mui-scroll">
									<ul class="mui-table-view regular-simple-list will-check-list">
										<li class="mui-table-view-cell mui-table" :class="{ 'color-orange': item.toExpire, 'color-pink': item.overdue }" :data-index="index" v-for="(item, index) in willCheckList" :key="item.id">
											<div class="mui-table-cell">{{ item.sb_name }}</div>
											<div class="mui-table-cell">最晚定检时间：{{ item.checkTime }}</div>
											<div class="mui-table-cell">{{ item.type === 0 ? '半年检' : '全年检' }}</div>
										</li>
									</ul>
									<div v-if="!willCheckList.length" class="list-nodata">暂无数据</div>
								</div>
							</div>
						</div>
					</div>
					<div id="item2" class="mui-control-content" :style="{height: height2 + 'px'}">
						<div id="scroll2" class="regular-scroll mui-scroll-wrapper">
							<div class="mui-scroll">
								<ul class="mui-table-view regular-draft-list">
									<li class="mui-table-view-cell" v-for="item in blowerDraftList" :key="item.id" @tap="toCheckCategory(item)">
										<div class="mui-table">
											<div class="mui-table-cell"><span class="label">风机编号：</span><span class="color-orange">{{ item.sbName }}</span></div>
											<div class="mui-table-cell mui-text-right">
												<span class="label">状态：</span><span :class="[item.status === 1 ? 'color-green' : 'color-pink']">{{ item.status === 0 ? '处理中' : '待提交' }}</span>
											</div>
										</div>
										<div class="manager">
											<div><span class="label">工作负责人：</span>{{ item.jobManager }}</div>
										</div>
										<div class="mui-table">
											<div class="mui-table-cell"><span class="label">最晚定检时间：</span>{{ item.checkTime }}</div>
											<div class="mui-table-cell mui-text-right">{{ item.type === 0 ? '半年检' : '全年检' }}</div>
										</div>
									</li>
								</ul>
								<div v-if="!blowerDraftList.length" class="list-nodata">暂无数据</div>
							</div>
						</div>
					</div>
					<div id="item3" class="mui-control-content" :style="{height: height2 + 'px'}">
						<div id="scroll3" class="regular-scroll mui-scroll-wrapper">
							<div class="mui-scroll">
								<ul class="mui-table-view regular-simple-list">
									<li class="mui-table-view-cell mui-table" v-for="item in recordList" :key="item.id">
										<div class="mui-table-cell">{{ item.sb_name }}</div>
										<div class="mui-table-cell">最晚定检时间：{{ item.checkTime }}</div>
										<div class="mui-table-cell">{{ item.type === 0 ? '半年检' : '全年检' }}</div>
									</li>
								</ul>
								<div v-if="!recordList.length" class="list-nodata">暂无数据</div>
							</div>
						</div>
					</div>
				</div>
				<!-- 弹窗 -->
				<div id="popover" class="mui-popover custom-dialog">
					<div class="custom-dialog-wrap">
						<h5 class="dialog-header">
							<span class="title">填写人员信息</span>
						</h5>
						<ul class="dialog-main mui-table-view select-member">
							<li class="mui-table-view-cell">
								<span class="label">风机编号</span>
								<span class="mui-pull-right">{{ currentCode }}</span>
							</li>
							<li class="mui-table-view-cell">
								<a id="manager" class="mui-navigate-right">
									<span class="label">工作负责人</span>
									<span class="mui-pull-right" style="margin-right: 20px;">{{ jobManager }}</span>
								</a>
							</li>
							<li class="mui-table-view-cell">
								<a id="members" class="mui-navigate-right flex">
									<span class="label" style="width: 75px;">工作班人员</span>
									<div class="members">{{ jobMembers }}</div>
								</a>
							</li>
						</ul>
						<div class="dialog-footer">
							<div class="mui-table">
								<div id="close" class="mui-table-cell mui-text-center color-blue">关闭</div>
								<div id="confirm" class="mui-table-cell mui-text-center color-blue hairline-left">确认</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/vue.js"></script>
		<script src="../../js/mkeyplus.base.js"></script>
		<script src="../../js/storage.js"></script>
		<script type="text/javascript">
			(function($) {
				var netStatus = null; // 网络状态
				var regularCheckVM = null; // 定检风机列表实例
				var currentItem = null; // 被点击的待处理项
				var localUpdateTime = null;
				var serverUpdateTime = ''; // 服务器端更新时间
				var managerId = ''; // 负责人id
				var groupIds = ''; // 班组人员id
				var userId = localStorage.getItem('userid'); // 当前登陆的user
				
				$.init();
				
				regularCheckVM = new Vue({
					el: '#container',
					data: {
						height1: 0, // 待定检列表高度
						height2: 0, // 草稿箱,定检记录列表高度
						willCheckList: [], // 待定检列表
						blowerDraftList: [], // 草稿箱
						recordList: [], // 定检记录
						jobManager: '', // 工作负责人
						jobMembers: '', // 班组成员
						currentCode: '', // 正待检
						syncing: false, // 正在同步数据
						currentTimeOrder: 'timeDown', // 默认进入时间由小到大 时间排序 timeDown timeUp 风机编号 codeDown codeUp
						currentCodeOrder: 'codeDown'
					},
					created:function() {
						this.initHeight();
					},
					methods: {
						// 设置高度
						initHeight: function() {
							var height = window.innerHeight - 95;
							this.height1 = height - 50;
							this.height2 = height;
						},
						// 巡检记录
						getRecordList: function() {
							var that = this;
							console.log('请求record')
							$.baseApp.httpRequst('/api/v2/inspection/syncDeviceInfo', {
									status: 1, // 已巡检
									wind: JSON.parse(localStorage.getItem('org_code')),
									// pageNumber: 1,
									// pageSize: 10
								},
								function(res) {
									console.log("定检记录：" + JSON.stringify(res));
									var data = res.data;
									if(res.status === 200) {
										var data = res.data;
										myStorage.setItem('blowerRecordList', data); // 获取最新数据后缓存
										// 更新展示数据
										that.handleWillCheckList(data, 'recordList')
									} else {
										$.toast(res.message, { type: 'div' })
									}
								}
							);
						},
						// 获取待定检列表
						getWillCheckList: function() {
							var that = this;
							$.baseApp.httpRequst('/api/v2/inspection/syncDeviceInfo', {
									status: 0, // 未巡检
									wind: JSON.parse(localStorage.getItem('org_code')),
									// pageNumber: 1,
									// pageSize: 10
								},
								function(res) {
									console.log("待定检：" + JSON.stringify(res));
									if(res.status === 200) {
										var draftIds = that.blowerDraftList.map(function(ele) {
											return ele.id;
										});
										console.log(JSON.stringify(draftIds))
										var data = res.data;
										// 先筛选掉已进入草稿箱的
										var outBlowerDraftList = data.filter(function(ele) {
											return draftIds.indexOf(ele.id) === -1;
										});
										console.log(JSON.stringify(outBlowerDraftList))
										myStorage.setItem('willCheckList', outBlowerDraftList); // 获取最新数据后缓存
										// 更新展示数据
										that.handleWillCheckList(outBlowerDraftList, 'willCheckList')
									} else {
										$.toast(res.message, { type: 'div' })
									}
								}
							);
						},
						// 处理待定检数据
						handleWillCheckList: function(data, list) {
							var now = Date.now();
							var end = now + 15 * 24 * 60 * 60 * 1000;
							var reg = /\d+/g;
							this[list] = data.map(function(ele) {
								var latest = new Date(ele.latest_time).setHours(23, 59, 59);
								ele.overdue = latest <= now;
								ele.toExpire = latest > now && latest <= end;
								ele.checkTime = ele.latest_time.slice(0, 10);
								ele.orderNumber = ele.sb_number.match(reg)[1];
								return ele;
							});
						},
						sortList: function(val, prev) {
							console.log('排序......')
							var tempArr = JSON.parse(JSON.stringify(this.willCheckList));
							if (val === 'code') {
								if (prev === 'timeDown' || prev === 'timeUP') {
									if (this.currentCodeOrder === 'codeDown') {
										tempArr.sort(function(prev, next) {
											return parseInt(prev.orderNumber) - parseInt(next.orderNumber);
										});
									} else {
										tempArr.sort(function(prev, next) {
											return parseInt(prev.orderNumber) - parseInt(next.orderNumber);
										}).reverse();
									}
								} else if (prev === 'codeDown') {
									tempArr.sort(function(prev, next) {
										return parseInt(prev.orderNumber) - parseInt(next.orderNumber);
									}).reverse();
									this.currentCodeOrder = 'codeUp'; // 风机编号由大到小
								} else {
									tempArr.sort(function(prev, next) {
										return parseInt(prev.orderNumber) - parseInt(next.orderNumber);
									});
									this.currentCodeOrder = 'codeDown'; // 风机编号由小到大
								}
							} else {
								if (prev === 'codeDown' || prev === 'codeUp') {
									if (this.currentTimeOrder === 'timeDown') {
										tempArr.sort(function(prev, next) {
											return new Date(prev.latest_time).getTime() - new Date(next.latest_time).getTime();
										});
									} else {
										tempArr.sort(function(prev, next) {
											return new Date(prev.latest_time).getTime() - new Date(next.latest_time).getTime();
										}).reverse();
									}
								} else if (prev === 'timeDown') {
									tempArr.sort(function(prev, next) {
										return new Date(prev.latest_time).getTime() - new Date(next.latest_time).getTime();
									}).reverse();
									this.currentTimeOrder = 'timeUp'; // 风机编号由大到小
								} else {
									tempArr.sort(function(prev, next) {
										return new Date(prev.latest_time).getTime() - new Date(next.latest_time).getTime();
									});
									this.currentTimeOrder = 'timeDown'; // 风机编号由小到大
								}
							}
							this.willCheckList = tempArr;
						},
						// 草稿箱 -> 检查大项
						toCheckCategory: function(item) {
							console.log(JSON.stringify(item))
							mui.openWindow({
								url: '../regularCheck/category.html',
								id: '../regularCheck/category.html',
								show: {
									duration: 350
								},
								extras: {
									itemId: item.id, // 风机id
									sb_name: item.sbName,
									type: item.type, // 0，半年检，1，全年检
									managerId: item.managerId,
									groupIds: item.groupIds,
									templateId: item.templateId,
									latestTime: item.latestTime // 最晚定检时间
								}
							})
						},
						// 同步草稿箱数据
						getDraftList: function() {
							var that = this;
							$.baseApp.httpRequst('/api/v2/inspection/findSubmitRecord', {
									wind: JSON.parse(localStorage.getItem('org_code')),
									pageNumber: 1,
									pageSize: 10
								},
								function(res) {
									console.log("草稿箱数据：" + JSON.stringify(res));
									if (res.status === 200) {
										var draftsIdsStr = res.data;
										if (draftsIdsStr) {
											var tempDraft = that.blowerDraftList.filter(function(ele) {
												return draftsIdsStr.indexOf(ele.id) === -1
											})
											that.blowerDraftList = tempDraft;
											// 更新storage中的数据
											var storageBlowerDraftList = myStorage.getItem('blowerDraftList') || [];
											var willStorageDraftData = storageBlowerDraftList.filter(function(ele) {
												return draftsIdsStr.indexOf(ele.id) === -1;
											});
											myStorage.setItem('blowerDraftList', willStorageDraftData);
										}
									} else {
										$.toast(res.message, { type: 'div' })
									}
								}
							);
						},
						// 获取所有人员
						getMembers: function() {
							var that = this;
							console.log('请求人员信息')
							$.baseApp.httpRequst('/api/v2/inspection/syncUserInfo', {
									wind: JSON.parse(localStorage.getItem('org_code'))
								},
								function(res) {
									console.log("人员列表：" + JSON.stringify(res));
									var data = res.data;
									if(res.status === 200) {
										myStorage.setItem('checkMembers', data); // 获取最新数据后缓存
									} else {
										$.toast(res.message, { type: 'div' })
									}
								}
							);
						},
					}
				})
				
				$('.regular-scroll').scroll({
					indicators: true //是否显示滚动条
				});
				
				// 获取模版数据
				function getItemTemplate() {
          // console.log("待检大项模版数据111111111111111：：" + localStorage.getItem('org_code'));
          console.log(JSON.parse(localStorage.getItem('org_code')))
					$.baseApp.httpRequst('/api/v2/inspection/syncCheckpointInfo', {
							wind: JSON.parse(localStorage.getItem('org_code'))
						},
						function(res) {
							// console.log("待检大项模版数据：：" + JSON.stringify(res));
							var data = res.data;
							if(res.status === 200) {
								myStorage.setItem('itemTemplate', data); // 存储最新模版
							} else {
								$.toast(data.message, { type: 'div' })
							}
						}
					);
				}
				
				$.plusReady(function() {
					netStatus = plus.networkinfo.getCurrentType();
					localUpdateTime = myStorage.getItem('checkUpdateTime');
					console.log(netStatus)
					
					// 先获取本地存储的草稿箱列表
					var storageBlowerDraftList = myStorage.getItem('blowerDraftList') || [];
					// 获取登陆账号下的草稿箱数据
					regularCheckVM.blowerDraftList = storageBlowerDraftList.filter(function(ele) {
						return ele.userId == userId;
					}).map(function(ele) {
						// 处理状态, 待处理：有大项检查到一半未完成的, 待提交: 已检查的大项都全部检查完成
						var status = ele.categoryList.every(function(item) {
							return item.status == 2; // 1 某一大项未全部完成 2 待提交 3 待处理(已提交过了)
						});
						ele.status = status ? 1 : 0;
						ele.checkTime = ele.latestTime.slice(0, 10);
						return ele;
					});
					
					// 自动同步数据 服务器拉取
					function initDataByServer() {
						regularCheckVM.getDraftList(); // 获取草稿箱
						regularCheckVM.getWillCheckList();
						regularCheckVM.getRecordList(); // 定检记录
					}
					
					// 离线缓存获取
					function initDataByStorage() {
						console.log(myStorage.getItem('willCheckList'))
						var storageWillCheck = myStorage.getItem('willCheckList') || [];
						var storageRecordList = myStorage.getItem('blowerRecordList') || [];
						regularCheckVM.handleWillCheckList(storageWillCheck, 'willCheckList');
						regularCheckVM.handleWillCheckList(storageRecordList, 'recordList');
					}
					
					// 查询更新时间
					function queryUpdateTime() {
						$.baseApp.httpRequst('/api/v2/inspection/findUpdateTime', {
								wind: JSON.parse(localStorage.getItem('org_code'))
							},
							function(res) {
								console.log("更新时间：" + JSON.stringify(res));
								if(res.status === 200) {
									serverUpdateTime = res.data;
									console.log(localUpdateTime)
									console.log(serverUpdateTime)
									initDataByServer();
									if (localUpdateTime !== serverUpdateTime) {
										myStorage.setItem('checkUpdateTime', serverUpdateTime)
										initDataByServer();
									} else {
										initDataByStorage();
									}
								} else {
									$.toast(res.message, { type: 'div' })
								}
							}
						);
					}
					
					// 有无网络
					if (netStatus > 1) {
						queryUpdateTime();
						getItemTemplate(); // 有网更新模版数据
						regularCheckVM.getMembers();
					} else {
						initDataByStorage();
					}
				});
				// 待检列表
				$('.will-check-list').on('tap', 'li', function() {
					var idx = this.dataset.index;
					currentItem = regularCheckVM.willCheckList[idx];
					regularCheckVM.currentCode = currentItem.sb_name;
					regularCheckVM.jobManager = currentItem.job_manager_name;
					regularCheckVM.jobMembers = currentItem.group_user_name;
					managerId = currentItem.job_manager;
					groupIds = currentItem.group_user;
					$('#popover').popover('toggle', this)
				});
				// 关闭
				document.getElementById('close').addEventListener('tap', function() {
					managerId = ''; // 清空被选中负责人
					groupIds = ''; // 清空被选中班组成员
					$('#popover').popover('hide');
				});
				// 确定
				document.getElementById('confirm').addEventListener('tap', function() {
					if (regularCheckVM.jobManager && regularCheckVM.jobMembers) {
						var templateList = myStorage.getItem('itemTemplate');
						var templateId = currentItem.templet_id; // 当前项对应的模版数据
						console.log(templateId)
						var currentItemTemplate = templateList.filter(function(ele) {
							return ele.id === templateId;
						});
						if (currentItemTemplate.length) {
							$('#popover').popover('hide');
							var extras = {
								itemId: currentItem.id,
								sb_name: currentItem.sb_name,
								managerId: managerId,
								groupIds: groupIds,
								type: currentItem.type,
								latestTime: currentItem.latest_time, // 最晚定检时间
								templateData: JSON.stringify(currentItemTemplate[0].checkflist),
								templateId: templateId
							}
							mui.openWindow({
								url: '../regularCheck/category.html',
								id: '../regularCheck/category.html',
								extras: extras
							});
							managerId = '' // 清除已选人员
							groupIds = ''
						} else {
							$.toast('未找到对应定检模板', { type: 'div' });
						}
					} else {
						$.toast('请选择相关人员', { type: 'div' });
					}
				});
				// 选择负责人
				document.getElementById('manager').addEventListener('tap', function() {
					mui.openWindow({
						url: '../regularCheck/radioMember.html',
						id: '../regularCheck/radioMember.html',
						show: {
							duration: 450
						},
						extras: {
							member: managerId
						},
						waiting: {
							autoShow: true
						}
					})
				});
				// 选择班组成员
				document.getElementById('members').addEventListener('tap', function() {
					mui.openWindow({
						url: '../regularCheck/checkboxMember.html',
						id: '../regularCheck/checkboxMember.html',
						extras: {
							member: groupIds
						},
						waiting: {
							autoShow: true
						}
					})
				});
				// 同步数据
				document.getElementById('sync').addEventListener('tap', function() {
					netStatus = plus.networkinfo.getCurrentType();
					if (netStatus <= 1) {
						$.toast('请在网络连接良好时同步数据', { type: 'div' });
						return;
					}
					regularCheckVM.syncing = true;
					regularCheckVM.getDraftList(); // 获取草稿箱
					getItemTemplate(); // 同步模版数据
					regularCheckVM.getWillCheckList();
					regularCheckVM.getRecordList(); // 定检记录
					setTimeout(function() {
						regularCheckVM.syncing = false;
						$.toast('数据同步成功', { type: 'div' });
					}, 3000);
				});
				// 监听检查大项提交
				window.addEventListener('updateDraftAndRecord', function(event){
					console.log('提交后更新数据')
					// 重新获取草稿箱,记录列表,待定检列表
					var tempDrafts = myStorage.getItem('blowerDraftList') || [];
					regularCheckVM.blowerDraftList = tempDrafts.filter(function(ele) {
						return ele.userId == userId;
					}).map(function(ele) {
						// 处理状态, 待处理：有大项检查到一半未完成的 1 或已经提交过的 3, 待提交: 已检查的大项都全部检查完成  2
						var status = ele.categoryList.every(function(item) {
							return item.status == 2;
						});
						ele.status = status ? 1 : 0;
						ele.checkTime = ele.latestTime.slice(0, 10);
						return ele;
					});
					regularCheckVM.getRecordList();
					regularCheckVM.getWillCheckList();
					netStatus = plus.networkinfo.getCurrentType();
					if (netStatus > 1) {
						regularCheckVM.getDraftList();
					}
				});
				// 监听确定人员
				window.addEventListener('confirmMember', function(e){
					console.log('确认人员')
					// 重新获取草稿箱,记录列表
					switch (e.detail.type) {
						case 'manager':
							regularCheckVM.jobManager = e.detail.names;
							managerId = e.detail.ids;
							break;
						case 'group':
							regularCheckVM.jobMembers = e.detail.names;
							groupIds = e.detail.ids;
							break;
						default:
							break;
					}
				});
				// 提交或保存到本地之后
				window.addEventListener('updateWillcheckAndDraft', function(event){
					var id = event.detail.id; // 风机id
					// 重新获取草稿箱,待定检列表
					var tempDrafts = myStorage.getItem('blowerDraftList') || [];
					regularCheckVM.blowerDraftList = tempDrafts.filter(function(ele) {
						return ele.userId == userId;
					}).map(function(ele) {
						// 处理状态, 待处理：有大项检查到一半未完成的, 待提交: 已检查的大项都全部检查完成
						var status = ele.categoryList.every(function(item) {
							return item.status == 2;
						});
						ele.status = status ? 1 : 0;
						ele.checkTime = ele.latestTime.slice(0, 10);
						return ele;
					});
					regularCheckVM.willCheckList = regularCheckVM.willCheckList.filter(function(ele) {
						return ele.id != id;
					});
					netStatus = plus.networkinfo.getCurrentType();
					if (netStatus > 1) {
						regularCheckVM.getDraftList();
					}
				});
			})(mui);
		</script>
	</body>
</html>
